<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/common.css"/>
		<link rel="stylesheet" type="text/css" href="css/index.css"/>
	</head>
	<body>
		<header>
			<img src="img/logo.png" style="height: 31px;margin: 7px 20px;" alt="">
			<div style="">
				欢迎您：admin
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<a href="/logout"><button type="button" style="">退出</button></a>
			</div>
		</header>
		<aside>
			<div>
				<dl>
					<dt><img src="img/user.png" alt="" />律师管理<img src="img/down.png" class="down" alt="" /></dt>
					<dd>
						<ul>
							<li data-tip = "0" data-href = "lawyer_list">律师列表</li>
							<li data-tip = "0" data-href = "lawyer_add">添加律师</li>
						</ul>
					</dd>
				</dl>
				<dl>
					<dt><img src="img/article.png" alt="" />文章管理<img src="img/down.png" class="down" alt="" /></dt>
					<dd>
						<ul>
							<li data-tip = "0" data-href = "article_list">文章列表</li>
							<li data-tip = "0" data-href = "article_add">发布文章</li>
						</ul>
					</dd>
				</dl>

				<dl>
					<dt><img src="img/set.png" alt="" />账号管理<img src="img/down.png" class="down" alt="" /></dt>
					<dd>
						<ul>
							<li data-tip = "0" data-href = "reset_pwd">修改密码</li>
						</ul>
					</dd>
				</dl>
			</div>
		</aside>
		<ul class="acrossTab">
			<li class="active" onclick="changeTab(this)"><span style="padding-right: 16px;">首页</span><em></em></li>
		</ul>
		<section>
			<div class="showIframe">
				<iframe src="home" width="100%" height="100%"></iframe>
			</div>
		</section>
		<!--<div class="zzc"></div>-->
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$(document).ready(function(){
				
				$('aside li').click(function(){
					var href = $(this).attr('data-href');
					var that = $(this).text();
					if ($(this).attr('data-tip') == 0) {
						$(this).attr('data-tip',1);
						$('.acrossTab li').removeClass('active');
						$('.acrossTab').append('<li onclick="changeTab(this)" class="active"><span>'+$(this).text()+'</span><i onclick="closeIframe(this,event)"></i><em></em></li>');
						$('.showIframe').addClass('hideIframe');
						$('section').append('<div class="showIframe"><iframe src="'+href+'" width="100%" height="100%"></iframe></div>');
					} else {
						$('.acrossTab li').each(function(){
							if ($(this).children('span').text() == that) {
								$(this).click();
							}
						})
					}
				})
				
				$('aside').height($(window).height() - 35);
				$('section').height($(window).height() - 79);
				$('section').width($(window).width() - 200);
				
				$(window).on("resize",function(){
					$('aside').height($(window).height() - 35);
					$('section').height($(window).height() - 79);
					$('section').width($(window).width() - 200);
				})
			})
			
			function closeIframe(obj,event){
				var index = $(obj).parent('li').index();
					
				if ($(obj).parent('li').hasClass('active')) {
					$(obj).parent('li').prev('li').addClass('active');
					$(obj).parent('li').remove();
					$('section .showIframe').eq(index).prev('.showIframe').removeClass('hideIframe');
				} else{
					$(obj).parent('li').remove();
				}
				
				$('section .showIframe').eq(index).remove();
				var t = $(obj).siblings('span').text();
				
				$('aside li').each(function(){
					if ($(this).text() == t) {
						$(this).attr('data-tip',0);
					}
				})
				
				event.stopPropagation();
			}

			function changeTab(obj){
				$(obj).addClass('active').siblings('li').removeClass('active');
				var i = $(obj).index();
				$('section .showIframe').eq(i).removeClass('hideIframe').siblings('.showIframe').addClass('hideIframe');
				console.log($('aside').attr('data-tip'))
				if($('aside').attr('data-tip') == 1){//点击
					$('section .showIframe').eq(i).find('iframe').attr('src', $('section .showIframe').eq(i).find('iframe').attr('src'));
					$('aside').attr('data-tip',0);
				}
			}
			
			
			document.onkeydown = function(event){
				var e = event || window.event || arguments.callee.caller.arguments[0];
				if(e && e.keyCode == 116){
					event.preventDefault();
					
					$('.showIframe').each(function(){
						if(!$(this).hasClass('hideIframe')){
							$(this).children('iframe').attr('src',$(this).children('iframe').attr('src'))
						}
					})
				}
			}
		</script>
	</body>
</html>
